<?php


namespace App\Libraries\Warehouse\Strategies;


use App\Libraries\Warehouse\Contracts\DockingBehavior;
use App\Libraries\Warehouse\StrategyAbstract;
use App\Models\Client;
use Illuminate\Database\Eloquent\Model;
use Exception;
use Illuminate\Support\Facades\Log;

class GetProduct extends StrategyAbstract implements DockingBehavior
{


    /**
     * @param $data array
     * @throws Exception
     * @author luffyzhao@vip.126.com
     */
    public function __construct($data)
    {
        if(!isset($data['sku'])){
            throw new Exception('sku 不能为空');
        }
        $this->data = $data;
    }

    /**
     * @return array
     * @author luffyzhao@vip.126.com
     */
    public function map(): array
    {
        $data = [
            'HeaderRequest' => $this->headerRequest(),
            'ProductSkuNo' => $this->data['sku']
        ];
        return $data;
    }

    /**
     * 获取 url
     * @return string
     * @author luffyzhao@vip.126.com
     */
    public function getUrl(): string
    {
        return 'http://hnoms.bestlucklog.com/default/product-soap/wsdl';
    }

    /**
     * @return string
     * @author luffyzhao@vip.126.com
     */
    public function getCallName()
    {
        return 'getProductinfo';
    }
}